<?php $this->load->view('header'); ?>
<?php
if ($msg = $this->session->flashdata('flash_message')) {
   //showMessage($msg['type'], $msg['msg']);
?>
    <script type="text/javascript">
        $.notify(
            "<?php echo $msg['msg']?>", 
            { 
               position:"top center",
                showAnimation: 'slideDown',
                autoHideDelay: 2000,
                className: 'success',
                hideAnimation: 'slideUp',
                autoHide: true,
                autoHideDelay: 3000
            }
        );
    </script>
<?php
}
?>

<div class="wrap-detail-project wrap-dashboard">
    <div class="container container-dashboard">
        <div class="row">
            <div class="col-lg-9 col-md-9 col-sm-9 col-xs-12 no-padding">
                <ul class="tab-dashboard">
                    <li class="active"><a href=""><?php echo $this->lang->line("Hire")?></a></li>
                    <li><a href=""><?php echo $this->lang->line("Manage")?></a></li>
                    <li><a href="<?php echo url_buyerEditProfile()?>"><?php echo $this->lang->line("Setting")?></a></li>
                </ul>
            </div>
            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-12 no-padding">
                <div class="search-dashboard">
                    <form action="" method="post" id="frm-search">
                        <select name="search_type" class="search-type">
                            <option><?php echo $this->lang->line('Freelancers')?></option>
                            <option><?php echo $this->lang->line('Jobs')?></option>
                        </select>
                        <input type="text" name="search" class="search" placeholder="<?php echo $this->lang->line('Find freelancers');?>">
                        <button type="submit" class="btn-search glyphicon glyphicon-search"></button>
                    </form>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 no-padding">
                <ul class="nav nav-pills tab-child">
                    <li class="active"><a href="<?php echo site_url('buyer/viewMyProjects');?>"><?php echo $this->lang->line("My jobs")?></a></li>
                    <li><a href="<?php echo site_url('buyer/savedFreelancers');?>"><?php echo $this->lang->line("Saved freelancers")?></a></li>
                    <li><a href="<?php echo site_url('buyer/messages');?>"><?php echo $this->lang->line("Messages")?></a></li>
                    <li><a href=""><?php echo $this->lang->line("All updates")?></a></li>
                </ul>
            </div>
        </div>
        <div class="row app-panel" id="my-jobs">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 no-padding app-panel-title">
                <div class="col-lg-1 col-md-1 col-sm-1 col-xs-3 search-title"><?php echo $this->lang->line('Hire')?></div>
                <div class="col-lg-9 col-md-9 col-sm-9 col-xs-6">
                    <form action="" method="post">
                        <input type="text" name="search_job" class="form-control form-input" placeholder="<?php echo $this->lang->line('Search for jobs')?>">
                        <button type="submit" class="btn-search glyphicon glyphicon-search"></button>
                    </form>
                </div>
                <div class="col-lg-2 col-md-2 col-sm-2 col-xs-3 padding-left">
                    <a href="<?php echo site_url('project/create'); ?>" class="btn btn-post-job"><?php echo $this->lang->line('Post job')?></a>
                </div>
            </div>
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 filter-job padding-left">
                <div class="col-lg-8 col-md-8 col-sm-8 col-xs-12 no-padding filter-job-title"><?php echo $this->lang->line('My jobs')?></div>
                <div class="col-lg-4 col-md-4 col-sm-4 col-xs-12 no-padding" style="text-align: right">
                    <form action="" method="POST">
                        <select class="selectpicker select-project-status" name="project_status">
                            <option value=''>All</option>
                            <option value='0' <?php echo (isset($params['st']) && $params['st'] == 0)?"selected":'';?>>Open</option>
                            <option value='1' <?php echo (isset($params['st']) && $params['st'] == 1)?"selected":'';?>>Pendding</option>
                            <option value='2' <?php echo (isset($params['st']) && $params['st'] == 2)?"selected":'';?>>Close</option>
                            <option value='3' <?php echo (isset($params['st']) && $params['st'] == 3)?"selected":'';?>>Canceled</option>
                        </select>
                    </form>
                </div>
            </div>
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <div class="table-projects row" id="reload-status-project">
                    <table class="col-lg-12 table col-md-12 col-sm-12 col-xs-12 no-padding">
                        <thead>
                        <tr class="x8-16-b">
                            <td class="col-lg-4"><?php echo $this->lang->line("Job")?></td>
                            <td class="col-lg-1" align="center"><?php echo $this->lang->line("Applicants")?></td>
                            <td class="col-lg-1" align="center"><?php echo $this->lang->line("Invited")?></td>
                            <td class="col-lg-1" align="center"><?php echo $this->lang->line("Messages")?></td>
                            <td class="col-lg-2" align="center"><?php echo $this->lang->line('Status'); ?></td>
                            <td class="col-lg-2" align="center"><?php echo $this->lang->line('Hired'); ?></td>
                            <td class="col-lg-2"><?php echo $this->lang->line('Share'); ?></td>
                        </tr>
                        </thead>
                        <tbody>
                        <?php
                        if ($myProjects -> num_rows() > 0) {
                            foreach ($myProjects->result() as $project) {
                                $programmer = getUserInfo($project->programmer_id);

                        ?>
                                <tr>
                                    <td class="xanh-14-b">
                                        <?php
                                        $link = site_url('project/view/'.$project->id);
                                        if($project->project_status == 0){
                                            $link = site_url('project/viewProjectAfterCreate/'.$project->id);
                                        }
                                        ?>
                                        <a href="<?php echo $link;?>"><?php echo $project->project_name; ?></a>
                                        <br><span><?php echo '$'.$project->budget_min . ' - $' . $project->budget_max . ' - ' . timeAgo($project->created)?></span>
                                    </td>
                                    <td align="center"><?php echo (getNumBid($project->id) > 0)?getNumBid($project->id):'-'?></td>
                                    <td align="center"><?php echo (getNumInvite($project->id) > 0)?getNumInvite($project->id):'-';?></td>
                                    <td align="center"><?php echo (getNumMessage($project->id) > 0)?getNumMessage($project->id):'-';?></td>
                                    <td align="center"><?php echo getProjectStatus($project->project_status)?></td>
                                    <td align="center"><?php echo (isset($programmer->user_name))?$programmer->user_name:'-';?></td>
                                    <td></td>
                                </tr>
                            <?php
                            }
                        }else{
                            echo "<tr><td colspan='6'>".$this->lang->line('No project')."</td></tr>";
                        }
                        ?>
                        </tbody>
                    </table>
                    <div class="dashboard-pagination text-center col-lg-12 col-md-12 col-sm-12 no-padding">
                        <?php if(isset($pagination)) echo $pagination;?>
                    </div> <!-- freelancer pagination -->
                </div> <!-- table-list-project -->

            </div>
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 no-padding job-popular-title"><?php echo $this->lang->line('Popular jobs on Applancer')?></div>
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 no-padding main-content">
                <ul id="flexiselDemo">
                    <?php
                    if (count($groups->result()) > 0) {
                        $dem = 0;
                        foreach ($groups->result() as $item) {
                            $dem++;
                            $logo = getLogoGroup($item->id);
                            ?>
                            <li>
                                <div class="bg-box">
                                    <div class="col-md-12 col-xs-12 col-sm-12 no-padding item-content <?php if ($dem % 4 == 0) echo "item-content-last"; ?>">
                                        <div class="img-item-app">
                                            <div class="border <?php echo $logo['border']?> col-md-5 col-xs-5 col-sm-5">
                                            </div>
                                            <?php echo $logo['icon'];?>
                                            <?php
                                            if(is_attachment_exists($item->attachment_avatar)){
                                                $link_image = prfile_url($item->attachment_avatar);
                                            }else{
                                                $link_image =  prfile_url('avt_project_default.png');
                                            }
                                            ?>

                                            <a href="<?php echo site_url('joblist/viewAlljoblistsUpdate/g/' . $item->id) ?>" title="<?php echo $item->group_name?>" class="">
                                                <img alt="<?php echo $item->group_name?>" src="<?php echo $link_image?>" class="img-responsive">
                                            </a>
                                        </div>
                                        <div class="info-item-app col-sm-12 col-md-12 col-xs-12">
                                            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 group-name">
                                                <?php echo $item->group_name?>
                                            </div>
                                            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                                                <?php echo $item->count_project. " ". $this->lang->line('Jobs posted')?>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </li>
                            <?php ($dem / 4 == 1) ? $dem = 0 : $dem = $dem; }
                    }?>
                </ul>
            </div>
        </div>
    </div>
</div>
<?php $this->load->view('footer'); ?>